#include <bits/stdc++.h>
using namespace std;
int n,m,a[100005],c[100005],T,b[260][5];
int main(){
	int a,b,c,d;
    freopen("arena.in","r",stdin);
    freopen("arena.out","w",stdout);
    cin>>n>>m;
    for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=m;i++){
		cin>>c[i];
	}
	cin>>T;
	for(int i=1;i<=T;i++){
		cin>>b[i][1]>>b[i][2]>>b[i][3]>>b[i][4];
	    cout<<a<<endl<<b<<endl<<c<<endl<<d<<endl;
    }
    return 0;
}
